package com.qiaofang.applet.service.other.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @author QF2019
 */
@Data
@NoArgsConstructor
@ApiModel("二手房上下架规则")
public class PropertyRules {

    @ApiModelProperty("房源核验码开关")
    private boolean verifyCode;

    @ApiModelProperty("房源核验二维码开关")
    private boolean verifyQrCode;

    @ApiModelProperty("房源委托编号开关")
    private boolean consignCode;

    @ApiModelProperty("图片开关")
    private boolean housePhoto;

    @ApiModelProperty("图片数量")
    private Integer housePhotoNum;

    @ApiModelProperty("房源实勘记录开关")
    private boolean propertySurvey;

    @ApiModelProperty("户型图开关")
    private boolean houseTypePhoto;

    @ApiModelProperty("房源VR开关")
    private boolean propertyVr;

    @ApiModelProperty("房源视频开关")
    private boolean propertyVideo;

    @ApiModelProperty("建房年代开关")
    private boolean completeYear;

    @ApiModelProperty("跟进记录天数开关")
    private boolean lastFollowDate;

    @ApiModelProperty("跟进记录天数")
    private Integer lastFollowDateNum;

    @ApiModelProperty("房源属性开关")
    private boolean privy;

    @ApiModelProperty("房源属性")
    private List<Integer> privyList;

    @ApiModelProperty("房源标签开关")
    private boolean propertyTags;

    @ApiModelProperty("优质房开关")
    private boolean recommend;

    @ApiModelProperty("聚焦房开关")
    private boolean focusProperty;

    @ApiModelProperty("速销房开关")
    private boolean rapidSales;

    @ApiModelProperty("保护房开关")
    private boolean protectStatus;

    @ApiModelProperty("房源标题开关")
    private boolean title;

    @ApiModelProperty("房源描述开关")
    private boolean content;

    @Override
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        }
        if(o == null || getClass() != o.getClass()) {
            return false;
        }

        PropertyRules that = (PropertyRules) o;
        return verifyCode == that.verifyCode &&
                verifyQrCode == that.verifyQrCode &&
                consignCode == that.consignCode &&
                housePhoto == that.housePhoto &&
                propertySurvey == that.propertySurvey &&
                houseTypePhoto == that.houseTypePhoto &&
                propertyVr == that.propertyVr &&
                propertyVideo == that.propertyVideo &&
                completeYear == that.completeYear &&
                lastFollowDate == that.lastFollowDate &&
                privy == that.privy &&
                propertyTags == that.propertyTags &&
                recommend == that.recommend &&
                focusProperty == that.focusProperty &&
                rapidSales == that.rapidSales &&
                protectStatus == that.protectStatus &&
                title == that.title &&
                content == that.content &&
                Objects.equals(housePhotoNum, that.housePhotoNum) &&
                Objects.equals(lastFollowDateNum, that.lastFollowDateNum) &&
                Objects.equals(privyList, that.privyList);

    }

    @Override
    public int hashCode() {
        return Objects.hash(verifyCode, verifyQrCode, consignCode, housePhoto, housePhotoNum, propertySurvey, houseTypePhoto, propertyVr, propertyVideo, completeYear, lastFollowDate, lastFollowDateNum, privy, privyList, propertyTags, recommend, focusProperty, rapidSales, protectStatus, title, content);
    }

    /**
     * 判断是否需要通过mongo库数据处理上下架
     * @return
     */
    public boolean isValidParam(){
        return (housePhoto && housePhotoNum != null && housePhotoNum >= 0) || houseTypePhoto || propertyVr || propertyVideo || completeYear || title || content;
    }

    @Override
    public String toString() {
        return "PropertyRules{" +
                "verifyCode=" + verifyCode +
                ", verifyQrCode=" + verifyQrCode +
                ", consignCode=" + consignCode +
                ", housePhoto=" + housePhoto +
                ", housePhotoNum=" + housePhotoNum +
                ", propertySurvey=" + propertySurvey +
                ", houseTypePhoto=" + houseTypePhoto +
                ", propertyVr=" + propertyVr +
                ", propertyVideo=" + propertyVideo +
                ", completeYear=" + completeYear +
                ", lastFollowDate=" + lastFollowDate +
                ", lastFollowDateNum=" + lastFollowDateNum +
                ", privy=" + privy +
                ", privyList=" + privyList +
                ", propertyTags=" + propertyTags +
                ", recommend=" + recommend +
                ", focusProperty=" + focusProperty +
                ", rapidSales=" + rapidSales +
                ", protectStatus=" + protectStatus +
                ", title=" + title +
                ", content=" + content +
                '}';
    }
}
